package com.dong.es.entity.searchparam.source;

import co.elastic.clients.elasticsearch.core.search.SourceFilter;
import com.dong.es.entity.EsBaseDTO;

import java.util.List;

/**
 * @description: Es 指定查询时不包含的字段
 * @author: 陈瑞东
 * @create: 2022-06-23 11:19
 */
public class EsExcludesSourceParam extends EsSourceParam{
    private static final long serialVersionUID = -8638669501404153306L;

    // 不包含字段
    private List<String> excludesField;

    public EsExcludesSourceParam(List<String> excludesField) {
        this.excludesField = excludesField;
    }

    @Override
    protected boolean valid(EsBaseDTO esBaseDTO) {
        return excludesField != null;
    }

    @Override
    public void loadTo(SourceFilter.Builder target) {
        target.excludes(excludesField);
    }
}
